home *** CD-ROM | disk | FTP | other *** search
/ Wayzata's Best of Shareware PC/Windows 2 / Wayzata's Best of Shareware 2.0 (Windows) (Wayzata Technology)(7112)(1994).bin / pc / dos / programg / zi_123 / gosub.zsl < prev    next >
Text File  |  1992-08-19  |  2KB  |  58 lines

  1. ; *****************************************************************************
  2. ;
  3. ; GOSUB.ZSL
  4. ;
  5. ; Date  : 07/05/92
  6. ; Author: Ben Morris
  7. ;
  8. ; ****************************************************************************
  9.  
  10. Int i                                   ; Declare our counter integer
  11.  
  12. Label loop                              ; This is the loop label
  13.  
  14. i++                                     ; Add one to the integer
  15.  
  16. If i > 50                               ; Is it > 50?
  17.     Dialog 50, 0                        ; If so, show this dialog.....
  18.  
  19.         @CHit any key to exit.
  20.  
  21.     EndDialog
  22.     ExitScript                          ; And exit.
  23. EndIf
  24.  
  25. Gosub writeit                           ; Jump to the place where we display
  26.                                         ;  the counter dialog.
  27.  
  28. Goto loop                               ; Once we've done that, loop back.
  29.  
  30. ; *****************************************************************************
  31.  
  32. Label writeit                           ; This is the label that we GoSub to
  33.                                         ;  when we want to display the dialog.
  34.  
  35. Dialog  20, 1                           ; Show the dialog....
  36.  
  37.     @C%i%
  38.  
  39. EndDialog
  40.  
  41. Return                                  ; 'Return' will jump us back to the
  42.                                         ;  line AFTER the last 'GoSub'.
  43.  
  44. #END
  45.  
  46.     In the example above, a dialog will be displayed 50 times, with a counter
  47.     integer shown.
  48.  
  49.     Z/Install maintains a 'Gosub Stack'.  When 'Gosub' is called, the stack
  50.     increases by one and saves the current position in the script file.  It then
  51.     jumps to the label specified with 'Gosub'.
  52.  
  53.     When Z/Install sees the 'Return' command, it will jump back to the position
  54.     saved at the last 'Gosub' call.  The stack decreases by one.
  55.  
  56.     You can have a maximum of 500 Gosub calls (who would need that many?) before
  57.     issuing a 'Return' command.
  58.